//package com.ling.pl.core.commons.springmvc;
//
//import com.ling.pl.core.commons.springmvc.constant.FailStatus;
//import com.ling.pl.core.commons.springmvc.constant.ResultField;
//import com.ling.pl.core.commons.springmvc.constant.ResultStatus;
//import org.springframework.core.MethodParameter;
//import org.springframework.core.annotation.Order;
//import org.springframework.http.MediaType;
//import org.springframework.http.converter.HttpMessageConverter;
//import org.springframework.http.server.ServerHttpRequest;
//import org.springframework.http.server.ServerHttpResponse;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * Created by bo.wang on 2016/9/27.
// */
//@Order(1)
//@ControllerAdvice(basePackages = "com.ling")
//public class CloudResponseBodyAdvice implements ResponseBodyAdvice<Object> {
//    @Override
//    public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> converterType) {
//        return true;
//    }
//
//    @Override
//    public Object beforeBodyWrite(
//            Object returnValue, MethodParameter methodParameter, MediaType mediaType,
//            Class<? extends HttpMessageConverter<?>> converterType,
//            ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
//
//		Map<String, Object> temp=new HashMap<String, Object>();
//		if (returnValue != null||(returnValue==null&&"void".equals(methodParameter.getParameterType().toString()))) {
//			temp.put(ResultField.STATUS, ResultStatus.SUCCESS);
//			temp.put(ResultField.DATA, returnValue);
//		}else{
//			temp.put(ResultField.STATUS, ResultStatus.FAIL);
//			temp.put(ResultField.ERROCODE, FailStatus.NULLDATA);
//			temp.put(ResultField.ERROMESSAGE, "空数据");
//		}
//		return temp;
//    }
//}
